﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Forms;

namespace DX_Recognize.UI
{
    public class DXPageControl : UserControl
    {

        public event EventHandler PageChanged;

        private int _currentPage = 1;
        private Button btnPrevious;
        private Button btnNext;
        private Label lblCurrentPage;
        private Label lblTotalPages;
        private Label everyPageLabel;
        private ComboBox tiaoNumBox;
        private Label label1;
        private Label allLabel;
        private Label label2;
        private Button button1;
        private Button button2;
        private TextBox textBox1;
        private int _totalPages = 1;


        public DXPageControl()
        {
            InitializeComponent();
            InitializeControls();
        }


        private void InitializeControls()
        {
            btnPrevious.Click += btnPrevious_Click;
            btnNext.Click += btnNext_Click;
        }

        private void PaginationControl_Load(object sender, EventArgs e)
        {

        }

        private void btnPrevious_Click(object sender, EventArgs e)
        {

        }

        private void btnNext_Click(object sender, EventArgs e)
        {

        }

        protected virtual void OnPageChanged(EventArgs e)
        {
            PageChanged?.Invoke(this, e);
            UpdateLabels();
        }


        private void UpdateLabels()
        {
            //lblCurrentPage.Text = $"当前页: {CurrentPage}";
            //lblTotalPages.Text = $"总页数: {TotalPages}";
        }

        public int CurrentPage
        {
            get => _currentPage;
            set
            {
                if (_currentPage != value)
                {
                    _currentPage = value;
                    UpdateLabels();
                }
            }
        }

        public int TotalPages
        {
            get => _totalPages;
            set
            {
                if (_totalPages != value)
                {
                    _totalPages = value;
                    UpdateLabels();
                }
            }
        }

        private void InitializeComponent()
        {
            this.btnPrevious = new System.Windows.Forms.Button();
            this.btnNext = new System.Windows.Forms.Button();
            this.lblCurrentPage = new System.Windows.Forms.Label();
            this.lblTotalPages = new System.Windows.Forms.Label();
            this.everyPageLabel = new System.Windows.Forms.Label();
            this.tiaoNumBox = new System.Windows.Forms.ComboBox();
            this.label1 = new System.Windows.Forms.Label();
            this.allLabel = new System.Windows.Forms.Label();
            this.label2 = new System.Windows.Forms.Label();
            this.button1 = new System.Windows.Forms.Button();
            this.button2 = new System.Windows.Forms.Button();
            this.textBox1 = new System.Windows.Forms.TextBox();
            this.SuspendLayout();
            // 
            // btnPrevious
            // 
            this.btnPrevious.Location = new System.Drawing.Point(60, 6);
            this.btnPrevious.Name = "btnPrevious";
            this.btnPrevious.Size = new System.Drawing.Size(34, 23);
            this.btnPrevious.TabIndex = 1;
            this.btnPrevious.Text = "<";
            this.btnPrevious.UseVisualStyleBackColor = true;
            this.btnPrevious.Click += new System.EventHandler(this.btnPrevious_Click);
            // 
            // btnNext
            // 
            this.btnNext.Location = new System.Drawing.Point(177, 6);
            this.btnNext.Name = "btnNext";
            this.btnNext.Size = new System.Drawing.Size(36, 23);
            this.btnNext.TabIndex = 2;
            this.btnNext.Text = ">";
            this.btnNext.UseVisualStyleBackColor = true;
            // 
            // lblCurrentPage
            // 
            this.lblCurrentPage.AutoSize = true;
            this.lblCurrentPage.Location = new System.Drawing.Point(110, 11);
            this.lblCurrentPage.Name = "lblCurrentPage";
            this.lblCurrentPage.Size = new System.Drawing.Size(52, 12);
            this.lblCurrentPage.TabIndex = 3;
            this.lblCurrentPage.Text = "第1/1页";
            // 
            // lblTotalPages
            // 
            this.lblTotalPages.AutoSize = true;
            this.lblTotalPages.Location = new System.Drawing.Point(619, 12);
            this.lblTotalPages.Name = "lblTotalPages";
            this.lblTotalPages.Size = new System.Drawing.Size(12, 12);
            this.lblTotalPages.TabIndex = 4;
            this.lblTotalPages.Text = "0";
            // 
            // everyPageLabel
            // 
            this.everyPageLabel.AutoSize = true;
            this.everyPageLabel.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
            this.everyPageLabel.Location = new System.Drawing.Point(450, 12);
            this.everyPageLabel.Name = "everyPageLabel";
            this.everyPageLabel.Size = new System.Drawing.Size(31, 12);
            this.everyPageLabel.TabIndex = 5;
            this.everyPageLabel.Text = "每页";
            // 
            // tiaoNumBox
            // 
            this.tiaoNumBox.FormattingEnabled = true;
            this.tiaoNumBox.Location = new System.Drawing.Point(487, 8);
            this.tiaoNumBox.Name = "tiaoNumBox";
            this.tiaoNumBox.Size = new System.Drawing.Size(55, 20);
            this.tiaoNumBox.TabIndex = 6;
            // 
            // label1
            // 
            this.label1.AutoSize = true;
            this.label1.Location = new System.Drawing.Point(558, 12);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(18, 12);
            this.label1.TabIndex = 7;
            this.label1.Text = "条";
            // 
            // allLabel
            // 
            this.allLabel.AutoSize = true;
            this.allLabel.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
            this.allLabel.Location = new System.Drawing.Point(595, 12);
            this.allLabel.Name = "allLabel";
            this.allLabel.Size = new System.Drawing.Size(18, 12);
            this.allLabel.TabIndex = 8;
            this.allLabel.Text = "共";
            // 
            // label2
            // 
            this.label2.AutoSize = true;
            this.label2.Location = new System.Drawing.Point(652, 12);
            this.label2.Name = "label2";
            this.label2.Size = new System.Drawing.Size(18, 12);
            this.label2.TabIndex = 9;
            this.label2.Text = "条";
            // 
            // button1
            // 
            this.button1.Location = new System.Drawing.Point(20, 6);
            this.button1.Name = "button1";
            this.button1.Size = new System.Drawing.Size(34, 23);
            this.button1.TabIndex = 10;
            this.button1.Text = "<<";
            this.button1.UseVisualStyleBackColor = true;
            // 
            // button2
            // 
            this.button2.Location = new System.Drawing.Point(225, 6);
            this.button2.Name = "button2";
            this.button2.Size = new System.Drawing.Size(36, 23);
            this.button2.TabIndex = 11;
            this.button2.Text = ">>";
            this.button2.UseVisualStyleBackColor = true;
            // 
            // textBox1
            // 
            this.textBox1.Location = new System.Drawing.Point(297, 8);
            this.textBox1.Name = "textBox1";
            this.textBox1.Size = new System.Drawing.Size(47, 21);
            this.textBox1.TabIndex = 12;
            // 
            // DXPageControl
            // 
            this.Controls.Add(this.textBox1);
            this.Controls.Add(this.button2);
            this.Controls.Add(this.button1);
            this.Controls.Add(this.label2);
            this.Controls.Add(this.allLabel);
            this.Controls.Add(this.label1);
            this.Controls.Add(this.tiaoNumBox);
            this.Controls.Add(this.everyPageLabel);
            this.Controls.Add(this.lblTotalPages);
            this.Controls.Add(this.lblCurrentPage);
            this.Controls.Add(this.btnNext);
            this.Controls.Add(this.btnPrevious);
            this.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
            this.Name = "DXPageControl";
            this.Size = new System.Drawing.Size(731, 35);
            this.Load += new System.EventHandler(this.DXPageControl_Load);
            this.ResumeLayout(false);
            this.PerformLayout();

        }

        private void DXPageControl_Load(object sender, EventArgs e)
        {

        }
    }
}

